/*
Joseph Ratway
Garrett Brown
Bret Parker
*/

//imports
import java.util.*;

public class Node
{
    private Node mParent = null;
    private Hashtable<Integer, Node> mChildren = null;
    public Board currentState = new Board();
    private int mScore = 0;
    public int mMinScore = 100000; // Just any big number.
	public int mMaxScore = 0;
    public int depth = 0;
    int numSpaces = 0;
    private int player = 0;
    public String move = "";
    public int depth;
    
    public Node()
	{
		this.mChildren = new Hashtable<Integer, Node>();
		return;
	}

	public Node(Node parent, int color)
	{
		this.mChildren = new Hashtable<Integer, Node>();
		this.setParent(parent);
        this.color = color;
		return;
	}
    
	public Node(Node parent, int color, Board state, String move)
	{
		this.mChildren = new Hashtable<Integer, Node>();
		this.setBoard(state);
		this.setParent(parent);
        this.color = color;
        this.move = move;
		return;
	}
    
    
    /*
   	public void setParent(Node parent)
	{
		if(parent != null){
			this.mParent = parent;
		}else{
			System.out.println("Node.setParent - Attempt to pass null value.");
		}
		return;
	}
    
    public void setBoard(Board state)
    {
        this.currentState.deepCopy(state);
        
        return;
    }
    
    public Node getParent()
	{
		return this.mParent;
	}
    
	public Node getChild(int ID)
	{
		if(this.mChildren.containsKey(ID)){
			return this.mChildren.get(ID);
		}else{
			System.out.println("Node.getChild - Child with this ID not found.");
			return null;
		}
	}
	
	public ArrayList<Node> getChildren()
	{
		ArrayList<Node> kids = new ArrayList<Node>();
		Iterator<Node> it = this.mChildren.values().iterator();
		while(it.hasNext())
			kids.add(it.next());
		
		return kids;
	}

    public int opponentPieces()
    {
        int numberOf = 0;
        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                if(this.currentState.currentBoard[i][j] != this.color && this.currentState.currentBoard[i][j] != 0 && this.currentState.currentBoard[i][j] != 4)
                {
                    numberOf++;
                }
            }
        }
        return numberOf;
    }
    public int myPieces()
    {
        int numberOf = 0;
        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                if(this.currentState.currentBoard[i][j] == this.color)
                {
                    numberOf++;
                }
            }
        }
        return numberOf;
    
    }
    public void setMinScore(int score)
    {
        thix.mMinScore = score;
    }
    
    public void setMaxScore(int score)
    {
        thix.mMaxScore = score;
    }
    
    public void setChild(int ID, Node child)
	{
		if(ID > -1 && ID < 65 && child != null){
			this.mChildren.put(ID, child);
			if(child.opponentPieces() < this.mMinScore){
				this.setMinScore(child.opponentPieces());
				if(this.mParent != null){
					 this.mMinScore = this.mParent.setMinScore;
				}
			}
			if(child.myPieces() > this.mMaxScore){
				this.setMaxScore(child.myPieces());
				if(this.mParent != null){
					 this.mMaxScore = this.mParent.setMaxScore;
				}
			}
		}else{
			System.out.println("Node.setChild - Attempt to pass null or invalid value.");
		}
		return;
	}
    */
}